package dao;

import com.sleepycat.bind.tuple.TupleBinding;
import com.sleepycat.bind.tuple.TupleInput;
import com.sleepycat.bind.tuple.TupleOutput;

public class MessageBinding extends TupleBinding {
	
	 public Object entryToObject(TupleInput ti) {
		 Message message = new Message();
		 
		 message.setTo(ti.readString());
		 message.setFrom(ti.readString());
		 message.setBody(ti.readString());
		 message.setCheck(Boolean.parseBoolean(ti.readString()));		 
		 return message;
    }
	 
	 public void objectToEntry(Object object, TupleOutput to) {
		 Message message = (Message)object;
		 to.writeString(message.getTo());
		 to.writeString(message.getFrom());
		 to.writeString(message.getBody());
		 to.writeString(message.isCheck()+"");
	 }
}
